 /* 
 * File:   cSentinel.cpp
 * Author: josep
 * 
 * Created on 24 / desembre / 2010, 01:01
 */

#include "cAutonomousAgent.h"

cAutonomousAgent::cAutonomousAgent() {
}

cAutonomousAgent::cAutonomousAgent(const cAutonomousAgent& orig) {
}

cAutonomousAgent::~cAutonomousAgent() {
}

void cAutonomousAgent::on(){
    sm->processTransition(TO_LEFT);
}

void cAutonomousAgent::off(){
    sm->processTransition(0);
}

bool cAutonomousAgent::isDead(){
    return sm->getCurrentState()->getId()==DEATH;
}

bool cAutonomousAgent::isOff(){
    return sm->getCurrentState()->getId()==OFF;
}

int cAutonomousAgent::ChangeFramestate(int trans, int oldSt, int newSt){
    if(trans==TO_RIGHT){
            SetSpeedX(GO);
    }else if(trans==TO_LEFT){
            SetSpeedX(-GO);
    }else if(trans==DIE){
        SetSpeedX(0);
        if(oldSt==MOVING_LEFT){
            newSt++;
        }
    }
    SetFrameState(GetViewState(newSt));

    return State<cLateralAgent>::CONTINUE;
}

void cAutonomousAgent::ToDie(){
    this->SetSurfaceType(NORTH_SURFACE, SOFT_SURFACE);
    this->SetSurfaceType(SOUTH_SURFACE, SOFT_SURFACE);
    this->SetSurfaceType(EAST_SURFACE, SOFT_SURFACE);
    this->SetSurfaceType(WEST_SURFACE, SOFT_SURFACE);
    cLateralAgent::ToDie();
}


